#include "gameobject.h"
#include "movestate.h"
#include "attackstate.h"

void AttackState::enter(GameObject *gameObject)
{
    gameObject->setColor(Qt::red);   // 进入攻击状态,设置对象为红色
    gameObject->setShouldStop(true); // 设置停止标记
}

void AttackState::handle(GameObject *gameObject)
{
    // 如果没有敌人在攻击范围, 那么切换状态为移动状态
    if (gameObject->isEnemyInRange() == false){
        gameObject->setState(new MoveState());
        return;
    }

    // 确保保持停止状态（防止其他地方修改）
    gameObject->setShouldStop(true);
}

void AttackState::exit(GameObject *gameObject)
{
    gameObject->setShouldStop(false);  // 退出时解除停止
}
